package com.hyt.it.ogt.kq.service.bm.schedule;

import com.hyt.it.ogt.kq.service.bm.service.IProjectService;
import com.hyt.it.ogt.kq.service.bm.service.IProjectStatisticService;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @program: it-ogt-bm
 * @description: 报名统计任务
 * @author: Yang HuanKun
 * @create: 2022-09-19 17:04
 **/
@Component
@Slf4j
public class ProjectStatisticJob {

    @Resource
    private IProjectService projectService;
    @Resource
    private IProjectStatisticService projectStatisticService;

    /**
     * 为需要统计数据的报名创建任务
     */
    @XxlJob("createProjectStatistic")
    public ReturnT<String> createProjectStatistic() {
        projectService.createProjectStatistic();
        return ReturnT.SUCCESS;
    }

    /**
     * 为已经过期了的统计数据的报名创建任务
     */
    @XxlJob("timeoutProjectStatistic")
    public ReturnT<String> timeoutProjectStatistic() {
        projectService.timeoutProjectStatistic();
        return ReturnT.SUCCESS;
    }

    /**
     * 删除不需要的报名统计数据
     */
    @XxlJob("deleteProjectStatistic")
    public ReturnT<String> deleteProjectStatistic() {
        projectStatisticService.deleteProjectStatistic();
        return ReturnT.SUCCESS;
    }
}
